/****************************************************************************
 * Copyright (C) 2025 Chenyz. All rights reserved.
 *
 * @file    TinyOS_MemBlock.h
 *
 * @par     dependencies
 *          - stdint.h (Standard integer types)
 *          - TinyOS_Types.h (Type definitions)
 *
 * @author  Chenyz
 *
 * @brief   Memory Block Management Header
 *          This file provides declarations for fixed-size memory block
 *          management in TinyOS, including:
 *          - Memory pool initialization and configuration
 *          - Block allocation and deallocation operations
 *          - Blocking and non-blocking memory requests
 *          - Memory pool information and cleanup
 *
 * @version V1.0
 * @date    2025-10-03
 *
 * @note    This module implements fixed-size memory block management
 *          for efficient dynamic memory allocation in embedded systems.
 ****************************************************************************/

#ifndef __TINYOS_MEMBLOCK_H__
#define __TINYOS_MEMBLOCK_H__

/******************************** Includes **********************************/
#include <stdint.h>
#include "TinyOS_Types.h"

/*************************** Function Declarations **************************/

/* Memory block management functions */
void TinyOS_MemBlockInit(
    TinyOS_MemBlockType* MemBlock,
    uint8_t* MemBlockStartAddr,
    uint32_t BlockSize,
    uint32_t BlockCount
);
void TinyOS_MemBlockGive(    
    TinyOS_MemBlockType* MemBlock,
    uint8_t* Mem
);
uint32_t TinyOS_MemBlockTakeNoWait(
    TinyOS_MemBlockType* MemBlock,
    uint8_t** Memory
);
uint32_t TinyOS_MemBlockTake(
    TinyOS_MemBlockType* MemBlock,
    uint8_t** Memory,
    uint32_t WaitTicks
);

void TinyOS_MemBlockGetInfo(
    TinyOS_MemBlockType* MemBlock,
    TinyOS_MemBlockInfo* Info
);

uint32_t TinyOS_MemBlockDelete(TinyOS_MemBlockType* MemBlock);

#endif /* __TINYOS_MEMBLOCK_H__ */

